import { useState } from "react";
import { Button } from "antd";
import { RotateRightOutlined, CloseOutlined, BorderOutlined, MinusOutlined } from '@ant-design/icons'

// 窗口控制工具：最小化，最大化，还原，关闭
export default function WinControlTool() {
  const [isFullScreen, setIsFullScreen] = useState(false);

  return <div className="flex gap-3">
    <Button
      className="app-region-no-drag"
      type="text"
      onClick={() => window.electron?.ipcRenderer.send('win:invoke', 'min')}
      icon={<MinusOutlined />} />
    {
      isFullScreen ? <Button
        className="app-region-no-drag"
        type="text"
        onClick={() => {
          setIsFullScreen(false)
          window.electron?.ipcRenderer.send('win:invoke', 'max')
        }}
        icon={<RotateRightOutlined rotate={90} />}
      /> : <Button
        className="app-region-no-drag"
        type="text"
        onClick={() => {
          setIsFullScreen(true)
          window.electron?.ipcRenderer.send('win:invoke', 'max')
        }}
        icon={<BorderOutlined />}
      />
    }
    <Button
      className="app-region-no-drag"
      type="text"
      onClick={() => window.electron?.ipcRenderer.send('win:invoke', 'close')}
      icon={<CloseOutlined />} />
  </div>
}
